#!/bin/bash
# 借助maven插件 根据Dockerfile构建镜像
# 开启Docker远程服务支持：
# ExecStart=/opt/kube/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
# systemctl daemon-reload && systemctl restart docker
SCRIPT_DIR=$(cd $(dirname $0); pwd)
# 本地Docker API
DOCKER_HOST=unix:///var/run/docker.sock
if [ -n "$1" ];then
    echo "Using REMOTE Docker API" "$1"  "to build image..."
    # sh build.sh tcp://192.168.1.222:2375
    DOCKER_HOST=$1
    cd "${SCRIPT_DIR}"/../../ &&  DOCKER_HOST=${DOCKER_HOST} mvn package
    exit 0
fi
# maven docker构建
echo "Using Local Docker to build image..."
cd "${SCRIPT_DIR}"/../../ &&  mvn package
